static unsigned mapkey(unsigned k) {
        unsigned ret;
        switch (k) {
        default: ret = AW_KEY_NONE; break;
	case GDK_a: ret = AW_KEY_A; break;
	case GDK_s: ret = AW_KEY_S; break;
	case GDK_d: ret = AW_KEY_D; break;
	case GDK_f: ret = AW_KEY_F; break;
	case GDK_h: ret = AW_KEY_H; break;
	case GDK_g: ret = AW_KEY_G; break;
	case GDK_z: ret = AW_KEY_Z; break;
	case GDK_x: ret = AW_KEY_X; break;
	case GDK_c: ret = AW_KEY_C; break;
	case GDK_v: ret = AW_KEY_V; break;
	case GDK_b: ret = AW_KEY_B; break;
	case GDK_q: ret = AW_KEY_Q; break;
	case GDK_w: ret = AW_KEY_W; break;
	case GDK_e: ret = AW_KEY_E; break;
	case GDK_r: ret = AW_KEY_R; break;
	case GDK_t: ret = AW_KEY_T; break;
	case GDK_y: ret = AW_KEY_Y; break;
	case GDK_1: ret = AW_KEY_1; break;
	case GDK_2: ret = AW_KEY_2; break;
	case GDK_3: ret = AW_KEY_3; break;
	case GDK_4: ret = AW_KEY_4; break;
	case GDK_6: ret = AW_KEY_6; break;
	case GDK_5: ret = AW_KEY_5; break;
	case GDK_equal: ret = AW_KEY_EQUAL; break;
	case GDK_9: ret = AW_KEY_9; break;
	case GDK_7: ret = AW_KEY_7; break;
	case GDK_minus: ret = AW_KEY_MINUS; break;
	case GDK_8: ret = AW_KEY_8; break;
	case GDK_0: ret = AW_KEY_0; break;
	case GDK_bracketright: ret = AW_KEY_RIGHTBRACKET; break;
	case GDK_o: ret = AW_KEY_O; break;
	case GDK_u: ret = AW_KEY_U; break;
	case GDK_bracketleft: ret = AW_KEY_LEFTBRACKET; break;
	case GDK_i: ret = AW_KEY_I; break;
	case GDK_p: ret = AW_KEY_P; break;
	case GDK_l: ret = AW_KEY_L; break;
	case GDK_j: ret = AW_KEY_J; break;
	case GDK_quoteright: ret = AW_KEY_QUOTE; break;
	case GDK_k: ret = AW_KEY_K; break;
	case GDK_semicolon: ret = AW_KEY_SEMICOLON; break;
	case GDK_backslash: ret = AW_KEY_BACKSLASH; break;
	case GDK_comma: ret = AW_KEY_COMMA; break;
	case GDK_slash: ret = AW_KEY_SLASH; break;
	case GDK_n: ret = AW_KEY_N; break;
	case GDK_m: ret = AW_KEY_M; break;
	case GDK_period: ret = AW_KEY_PERIOD; break;
	case GDK_grave: ret = AW_KEY_GRAVE; break;
	case GDK_KP_Decimal: ret = AW_KEY_KEYPADDECIMAL; break;
	case GDK_KP_Multiply: ret = AW_KEY_KEYPADMULTIPLY; break;
	case GDK_KP_Add: ret = AW_KEY_KEYPADPLUS; break;
//	case GDK_KeypadClear: ret = AW_KEY_KEYPADCLEAR; break;
	case GDK_KP_Divide: ret = AW_KEY_KEYPADDIVIDE; break;
	case GDK_KP_Enter: ret = AW_KEY_KEYPADENTER; break;
	case GDK_KP_Subtract: ret = AW_KEY_KEYPADMINUS; break;
	case GDK_KP_Equal: ret = AW_KEY_KEYPADEQUALS; break;
	case GDK_KP_0: ret = AW_KEY_KEYPAD0; break;
	case GDK_KP_1: ret = AW_KEY_KEYPAD1; break;
	case GDK_KP_2: ret = AW_KEY_KEYPAD2; break;
	case GDK_KP_3: ret = AW_KEY_KEYPAD3; break;
	case GDK_KP_4: ret = AW_KEY_KEYPAD4; break;
	case GDK_KP_5: ret = AW_KEY_KEYPAD5; break;
	case GDK_KP_6: ret = AW_KEY_KEYPAD6; break;
	case GDK_KP_7: ret = AW_KEY_KEYPAD7; break;
	case GDK_KP_8: ret = AW_KEY_KEYPAD8; break;
	case GDK_KP_9: ret = AW_KEY_KEYPAD9; break;
	case GDK_Return: ret = AW_KEY_RETURN; break;
	case GDK_Tab: ret = AW_KEY_TAB; break;
	case GDK_space: ret = AW_KEY_SPACE; break;
	case GDK_Delete: ret = AW_KEY_DELETE; break;
	case GDK_Escape: ret = AW_KEY_ESCAPE; break;
	case GDK_Meta_L: ret = AW_KEY_COMMAND; break;
	case GDK_Shift_L: ret = AW_KEY_SHIFT; break;
	case GDK_Caps_Lock: ret = AW_KEY_CAPSLOCK; break;
	case GDK_Alt_L: ret = AW_KEY_OPTION; break;
	case GDK_Control_L: ret = AW_KEY_CONTROL; break;
	case GDK_Shift_R: ret = AW_KEY_RIGHTSHIFT; break;
	case GDK_Alt_R: ret = AW_KEY_RIGHTOPTION; break;
	case GDK_Control_R: ret = AW_KEY_RIGHTCONTROL; break;
	case GDK_function: ret = AW_KEY_FUNCTION; break;
	case GDK_F17: ret = AW_KEY_F17; break;
	case GDK_AudioLowerVolume: ret = AW_KEY_VOLUMEUP; break;
	case GDK_AudioRaiseVolume: ret = AW_KEY_VOLUMEDOWN; break;
	case GDK_AudioMute: ret = AW_KEY_MUTE; break;
	case GDK_F18: ret = AW_KEY_F18; break;
	case GDK_F19: ret = AW_KEY_F19; break;
	case GDK_F20: ret = AW_KEY_F20; break;
	case GDK_F5: ret = AW_KEY_F5; break;
	case GDK_F6: ret = AW_KEY_F6; break;
	case GDK_F7: ret = AW_KEY_F7; break;
	case GDK_F3: ret = AW_KEY_F3; break;
	case GDK_F8: ret = AW_KEY_F8; break;
	case GDK_F9: ret = AW_KEY_F9; break;
	case GDK_F11: ret = AW_KEY_F11; break;
	case GDK_F13: ret = AW_KEY_F13; break;
	case GDK_F16: ret = AW_KEY_F16; break;
	case GDK_F14: ret = AW_KEY_F14; break;
	case GDK_F10: ret = AW_KEY_F10; break;
	case GDK_F12: ret = AW_KEY_F12; break;
	case GDK_F15: ret = AW_KEY_F15; break;
	case GDK_Help: ret = AW_KEY_HELP; break;
	case GDK_Home: ret = AW_KEY_HOME; break;
	case GDK_Page_Up: ret = AW_KEY_PAGEUP; break;
	case GDK_Clear: ret = AW_KEY_FORWARDDELETE; break;
	case GDK_F4: ret = AW_KEY_F4; break;
	case GDK_End: ret = AW_KEY_END; break;
	case GDK_F2: ret = AW_KEY_F2; break;
	case GDK_Page_Down: ret = AW_KEY_PAGEDOWN; break;
	case GDK_F1: ret = AW_KEY_F1; break;
	case GDK_leftarrow: ret = AW_KEY_LEFTARROW; break;
	case GDK_rightarrow: ret = AW_KEY_RIGHTARROW; break;
	case GDK_downarrow: ret = AW_KEY_DOWNARROW; break;
	case GDK_uparrow: ret = AW_KEY_UPARROW; break;
	}
	return ret;
}

